const {RolePermission} = require("../db/seq")
// const {Menu} = require("../db/seq")

class RolePermissionServe {
    async saveRolePermissionServe(roleId, permissionId, createdByUserId) {
        const res = await RolePermission.create({roleId, permissionId, createdByUserId})
        return res.dataValues;
    }

    async updateRolePermissionServe(roleId, permissionId, createdByUserId) {
        const res = await RolePermission.update({roleId, permissionId, createdByUserId}, {
            where: {
                roleId
            }
        })
        return res ? res : null;
    }

    async getRolePermissionByIdServe(roleId) {
        const res = await RolePermission.findAll({
            where: {
                roleId
            },
            attributes: {exclude: ['deletedTime', 'createdByUserId']},
        })
        return res ? res : null
    }
}

module.exports = new RolePermissionServe()
